﻿using System.Collections.Generic;
using System.IO;
using Duo1JHttpServer.Framework.Enum;

namespace Duo1JHttpServer.Framework.Model
{
    public class RequestModel
    {
        /// <summary>
        /// http请求方法
        /// </summary>
        public RequestType RequestType { get; set; }

        /// <summary>
        /// http请求url
        /// </summary>
        public string RequestUrl { get; set; }

        /// <summary>
        /// http协议版本
        /// </summary>
        public string ProtocolVersion { get; set; }

        /// <summary>
        /// 请求参数
        /// </summary>
        public Dictionary<string, string> RequestParams { get; set; }

        /// <summary>
        /// header参数表
        /// </summary>
        public Dictionary<string, string> HttpHeaders { get; set; }

        /// <summary>
        /// 输出流
        /// </summary>
        public StreamWriter OutputWriter { get; set; }

        /// <summary>
        /// 获取请求参数
        /// </summary>
        /// <returns>请求参数值</returns>
        public string GetAttribute(string key)
        {
            return RequestParams.TryGetValue(key, out string res) ? res : null;
        }
    }
}